﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Portal.Xml.Utility;

namespace Portal.Cms.Model
{
    public class PublicGroupDataFolderCls
    {
        public string PublicGroupDataFolderId;
        public string GroupDataId;
        public string FolderName;
        public string Description;
        public string ParentPublicGroupDataFolderId;
        public int SortIndex;
    }

    public class PublicGroupDataFolderParser
    {
        public static PublicGroupDataFolderCls CreateInstance()
        {
            //tao 1 class trang....
            PublicGroupDataFolderCls oPublicGroupDataFolderCls = new PublicGroupDataFolderCls();
            return oPublicGroupDataFolderCls;
        }

        public static PublicGroupDataFolderCls ParseFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            PublicGroupDataFolderCls oPublicGroupDataFolderCls = ParseFromDataRow(ds.Tables[0].Rows[0]);
            return oPublicGroupDataFolderCls;
        }


        public static PublicGroupDataFolderCls ParseFromDataRow(DataRow dr)
        {
            PublicGroupDataFolderCls oPublicGroupDataFolderCls = new PublicGroupDataFolderCls();
            oPublicGroupDataFolderCls.PublicGroupDataFolderId = XmlUtility.GetString(dr, "PublicGroupDataFolderId", true);
            oPublicGroupDataFolderCls.GroupDataId = XmlUtility.GetString(dr, "GroupDataId", true);
            oPublicGroupDataFolderCls.FolderName = XmlUtility.GetString(dr, "FolderName", true);
            oPublicGroupDataFolderCls.Description = XmlUtility.GetString(dr, "Description", true);
            oPublicGroupDataFolderCls.Description = XmlUtility.GetString(dr, "Description", true);
            oPublicGroupDataFolderCls.ParentPublicGroupDataFolderId = XmlUtility.GetString(dr, "frkParentPublicGroupDataFolderId", true);
            oPublicGroupDataFolderCls.SortIndex = XmlUtility.GetInt(dr, "SortIndex", true);

            return oPublicGroupDataFolderCls;
        }

        public static PublicGroupDataFolderCls[] ParseFromDataTable(DataTable dtTable)
        {
            PublicGroupDataFolderCls[] PublicGroupDataFolders = new PublicGroupDataFolderCls[dtTable.Rows.Count];
            for (int iIndex = 0; iIndex < dtTable.Rows.Count; iIndex++)
            {
                PublicGroupDataFolders[iIndex] = ParseFromDataRow(dtTable.Rows[iIndex]);
            }

            return PublicGroupDataFolders;
        }

        public static PublicGroupDataFolderCls[] ParseMultiRecordFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            if (ds.Tables.Count == 0)
            {
                return new PublicGroupDataFolderCls[0];
            }
            PublicGroupDataFolderCls[] PublicGroupDataFolders = new PublicGroupDataFolderCls[ds.Tables[0].Rows.Count];
            for (int iIndex = 0; iIndex < ds.Tables[0].Rows.Count; iIndex++)
            {
                PublicGroupDataFolders[iIndex] = ParseFromDataRow(ds.Tables[0].Rows[iIndex]);
            }
            return PublicGroupDataFolders;
        }
    }
}

